package genetic.q3.functions.math;

import genetic.Function;
import genetic.TreeNode;
import genetic.q3.functions.Computable;
import genetic.q3.functions.SymbolicRegressionFunction;

public class pow extends SymbolicRegressionFunction{

	public pow() {
		super(null);
	}
	
	public pow(TreeNode[] kids) {
		super(kids);
	}

	@Override
	public Function createInstance(TreeNode[] kids) {
		return new pow(kids);
	}

	@Override
	public TreeNode createRandomInstance(TreeNode[] kids) {
		return new pow(kids);
	}

	@Override
	public int getNumKids() {
		return 2;
	}

	@Override
	public String getName() {
		return "pow";
	}

	@Override
	public double compute(double xVal) {
		double val1 = ((Computable)kids[0]).compute(xVal);
		double val2 = ((Computable)kids[1]).compute(xVal);
		return Math.pow(val1, Math.round(val2));
	}
}
